package com.kgis.fm.business.model;

import java.util.Iterator;

import com.kgis.kp.model.Model;

public class Entity implements Model {
	
	private static final long serialVersionUID = 2249509879028902065L;
	private long fid;
	private int fno;
	private int cno;

	private ExtensionAttributes attributes;
	
	public int getFno() {
		return fno;
	}
	public void setFno(int fno) {
		this.fno = fno;
	}
	public int getCno() {
		return cno;
	}
	public void setCno(int cno) {
		this.cno = cno;
	}
	
	public long getFid() {
		return fid;
	}
	public void setFid(long fid) {
		this.fid = fid;
	}
	public ExtensionAttributes getAttributes() {
		return attributes;
	}
	public void setAttributes(ExtensionAttributes attributes) {
		this.attributes = attributes;
	}

	public void setAttributeValue(String key, Object value) {
		if (null != key) {
			if (null == attributes) {
				attributes = new ExtensionAttributes();
			}
			attributes.put(key, value);
		}
	}

	public Object getAttributeValue(String key) {
		if (null != attributes) {
			return attributes.get(key);
		}
		return null;
	}

	public String toString() {
		if (null != attributes) {
			StringBuffer buffer = new StringBuffer();
			Iterator<String> iterator = attributes.keySet().iterator();
			while (iterator.hasNext()) {
				String key = (String) iterator.next();
				Object value = attributes.get(key);
				if (buffer.length() > 0) {
					buffer.append(", ");
				}
				buffer.append(key + ":" + value);
			}
			return buffer.toString();

		}
		return null;
	}
	public boolean beNew() {
		return this.fid <= 0;
	}

}
